package cc.chenwenxi.sdk.rainbow;

import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinPwmOutput;
import com.pi4j.io.gpio.RaspiPin;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class FanKit {
	private static final GpioPinPwmOutput fun = GpioFactory.getInstance().provisionPwmOutputPin(RaspiPin.GPIO_01);
	/**
	 * 设置风扇转速0-1023
	 * @param speed
	 */
	public void speed(int speed) {
		if(speed > 1023) {
			speed  = 1023;
		}
		fun.setPwm(speed);
		log.info("设置风扇转速为:{}",speed);
	}
}
